package com.hmall.common.client;

import com.hmall.common.dto.FiltersDto;
import com.hmall.common.dto.PageDTO;
import com.hmall.common.pojo.Filters;
import com.hmall.common.pojo.Item;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
 *   Description ItemClient
 *   @author zhangyan
 *   @time   2024/11/13
 */
@FeignClient(name = "itemservice")
@RequestMapping("/item")
public interface ItemClient {
    @PostMapping("/selectfilter")
    public Filters selectFilters(@RequestBody FiltersDto filtersDto);

    @PostMapping("/list")
    PageDTO<Item> searchByCondition(FiltersDto filtersDto);


    @GetMapping("/{id}")
    public Item getById(@PathVariable Long id);

    //扣减库存
    @PutMapping("/stock/{itemId}/{num}")
    void updateStock(@PathVariable("itemId") Long id, @PathVariable("num") Integer num);

    @PutMapping("restock/{itemId}/{num}")
        //恢复库存
    void rebackStock(@PathVariable("itemId") Long id, @PathVariable("num") Integer num);

    @GetMapping("/hot")
    List<Item> hotItems();
}
